Skip to Content

Client Connection & Connection Policy

This document describes connection behavior in the current PlayServ Unity SDK.


Connection states

PlayServ.State can be:

  • Offline
  • Connecting
  • Handshaking
  • Online
  • Reconnecting

These values are defined by Playserv.Proxy.Common.PlayServState.


Connection setup

Connection policy is configured before connect:

var settings = new PlayServSettings { GameAccessToken = "your-token", GameId = "game-001", UserId = "player-001", GameVersion = "1.0.0", AllowMultipleConnections = true, RemoteEndpoint = PlayServSettings.DefaultRemoteEndpoint }; PlayServ.Config(settings); var connected = await PlayServ.Connect();

AllowMultipleConnections is sent in handshake config and interpreted by backend policy.


Monitoring connection state

private PlayServState _lastState = PlayServState.Offline; private void Update() { if (PlayServ.State == _lastState) return; _lastState = PlayServ.State; Debug.Log($"PlayServ state changed: {_lastState}"); }

Transport errors

Use transport error callback for policy/handshake failures:

PlayServ.OnTransportError += error => { Debug.LogError($"PlayServ transport error: {error.Code} - {error.Message}"); };

Reconnection

When connection is lost after Online, SDK moves to Reconnecting and performs reconnect attempts automatically.

If reconnection is not possible, state returns to Offline.


Summary

Connection policy in the Unity SDK is driven by PlayServSettings + backend handshake rules, while runtime state and errors are observed via PlayServ.State and PlayServ.OnTransportError.

Last updated on